@extends('company.company')

@section('title','企业中心')
@section('rightcontainer')
@include('front.common.editor')
<div class="col-xs-10" style="padding-right: 0;">
    <div class="bord-1 font-16 backgr-color-white">
        <div class="color-1 padd-15 boderbottom">职位编辑</div>
        @if($userinfo->company_id >0)
        <div class="form company-center-form" style="width:570px;margin: 30px auto;">
            @if (count($errors) > 0)
                <div class="alert alert-danger">
                    <strong>抱歉!</strong> 您的输入有问题，请检查后重新输入.<br><br>
                    <ul>
                        @foreach ($errors->all() as $error)
                            <li>{{ $error }}</li>
                        @endforeach
                    </ul>
                </div>
            @endif
            <form method="post" action="{{ asset('company/center/jobs/save') }}" id="jobForm">
              <div class="form-group clearfix">
                 <div class="col-xs-12 col-sm-3 col-3 ft-16 cor-2">职位类别<small class="color-red">*</small>：</div>
                 <div class="col-sm-9 col-xs-12"> 
                    <select name="cat_id" id="" class="form-control">
                      {!! $options !!}
                    </select>
                </div>
              </div>
              <div class="form-group clearfix">
                <div class="col-xs-12 col-sm-3 col-3 ft-16 cor-2">职位名称<small class="color-red">*</small>：</div>
                <div class="col-sm-9 col-xs-12"> 
                    <input type="text" class="form-control" name="title" value="@if(!empty($job)){{ $job->title }} @endif" placeholder="请输入职位名称">
                </div>
              </div>
              <div class="form-group clearfix">
                <div class="col-xs-12 col-sm-3 col-3 ft-16 cor-2">工作年限<small class="color-red">*</small>：</div>
                <div class="col-sm-9 col-xs-12"> 
                    <select name="gznx" class="form-control" id="">
                      @foreach ($gznx as $k => $gx)
                        <option value="{{ $k }}" @if(!empty($job)) @if($k == $job->gznx) selected @endif @endif>{{ $gx }}</option>
                      @endforeach
                    </select>
                </div>
              </div>
              <div class="form-group clearfix">
                <div class="col-xs-12 col-sm-3 col-3 ft-16 cor-2">工作性质<small class="color-red">*</small>：</div>
                <div class="col-sm-9 col-xs-12"> 
                    <ul id="job_nature">
                        <li class="@if(!empty($job)) @if($job->gzxz == 0) color-white backgr-color-4 @else backgr-color-main @endif @else backgr-color-main @endif margin-r-15" >全职</li>
                        <li class="@if(!empty($job)) @if($job->gzxz == 1) color-white backgr-color-4 @else backgr-color-main @endif @else backgr-color-main @endif margin-r-15">兼职</li>
                        <li class="@if(!empty($job)) @if($job->gzxz == 2) color-white backgr-color-4 @else backgr-color-main @endif @else backgr-color-main @endif margin-r-15">实习</li>
                    </ul>
                </div>
              </div>
              <div class="form-group clearfix">
                <div class="col-xs-12 col-sm-3 col-3 ft-16 cor-2">薪资<small class="color-red">*</small>：</div>
                <div class="col-sm-5 col-xs-12"> 
                    <input type="number" name="salary_lower" class="form-control" value="{{empty($job)?0:$job->salary_lower}}">
                    <div class="help-block">单位：K，均为0的时候，为面议</div>
                </div>
                <div class="col-sm-4 col-xs-12"> 
                    <input type="number" name="salary_high" class="form-control"  value="{{empty($job)?0:$job->salary_high}}">
                </div>
              </div>
              <div class="form-group clearfix">
                <div class="col-xs-12 col-sm-3 col-3 ft-16 cor-2">招聘人数<small class="color-red">*</small>：</div>
                <div class="col-sm-9 col-xs-12"> 
                    <input type="text" name="recruitment" class="form-control" value="@if($blademode == 'edit') {{ $job->recruitment }} @endif">
                </div>
              </div>
              <div class="form-group clearfix">
                     <div class="col-xs-12 col-sm-3 col-3 ft-16 cor-2">工作城市<small class="color-red">*</small>：</div>
                     <div class="col-sm-3 col-xs-12"> 
                        <select class="form-control" onchange="childAreas(this.value,'areas','city')" name="province" id="province">
                            <option>---选择省份---</option>
                            @foreach($area as $are)
                            <option value="{{$are->area_id}}" @if(!empty($job)) @if($select_province->area_id == $are->area_id) selected @endif @endif>{{$are->title}}</option>
                            @endforeach
                        </select>
                    </div>
                    <div class="col-sm-3 col-xs-12">
                        <select class="form-control" onchange="childAreas(this.value,'areas','area')" name="area" id="city">
                            <option>---选择市---</option>
                            @if($blademode == 'edit')
                            @foreach($subarea as $subare)
                            <option value="{{$subare->area_id}}" @if(!empty($job)) @if($select_city->area_id == $subare->area_id) selected @endif @endif>{{$subare->title}}</option>
                            @endforeach
                            @endif
                        </select>
                    </div>

              </div>
              <div class=" form-group clearfix">
                <div class="col-xs-12 col-sm-3 col-3 ft-16 cor-2">最低学历<small class="color-red">*</small>：</div>
                <div class="col-sm-9 col-xs-12"> 
                    <select name="degree" id="" class="form-control">
                      @foreach ($degree as $k => $dgr)
                        <option value="{{ $k }}" @if(!empty($job)) @if($k == $job->degree) selected @endif @endif >{{ $dgr }}</option>
                      @endforeach
                    </select>
                </div>
              </div>
              <div class="form-group clearfix">
                <div class="col-xs-12 col-sm-3 col-3 ft-16 cor-2">岗位职责<small class="color-red">*</small>：</div>
                <div class="col-sm-9 col-xs-12"> 
                    <textarea class="form-control content" name="intro" row="3">@if(!empty($job)) {!! $job->intro !!} @endif </textarea>
                </div>
              </div>
              <div class="form-group clearfix">
                <div class="col-xs-12 col-sm-3 col-3 ft-16 cor-2">任职要求<small class="color-red">*</small>：</div>
                <div class="col-sm-9 col-xs-12"> 
                    <textarea class="form-control content" name="description" row="5">@if(!empty($job)) {!! $job->description !!} @endif</textarea>
                </div>
              </div>
              {{--<div class="form-group clearfix">
                <div class="col-xs-12 col-sm-3 col-3 ft-16 cor-2">职位状态<small class="color-red">*</small>：</div>
                <div class="col-sm-9 col-xs-12"> 
                    <div class="checkbox">
                      <label><input type="radio" class="" name="status" @if(!empty($job)) @if($job->status == 1) checked @endif @endif value="1"> 开启</label>
                      <label><input type="radio" class="" name="status" @if(!empty($job)) @if($job->status == 3) checked @endif @endif value="3"> 关闭</label>
                    </div>
                </div>
              </div>--}}
              <div class="form-group clearfix">
                <div class="col-xs-12 col-sm-3 col-3 ft-16 cor-2">是否开启考试：</div>
                <div class="col-sm-9 col-xs-12">
                    <div class="checkbox" style="margin: 0">
                       <label>
                        <input type="radio" id="radio1" onclick="examinations()" name="test" value="0"  @if(!empty($job)&&$job->test == 0) checked @else checked @endif> 不开启
                       </label>
                       <label>
                        <input type="radio" id="radio2" onclick="examinations()" name="test" value="1"  @if(!empty($job)&&$job->test == 1) checked @endif> 开启
                       </label>
                    </div>
                </div>
              </div>
              <div class="form-group clearfix" id="examination">
                    <div class="col-xs-12 col-sm-3 col-3 ft-16 cor-2">试卷编号：</div>
                    <div class="col-sm-9 col-xs-12">
                        <select name="exam_id" class="form-control" id="examid">
                            @if(count($examinations)<= 0)
                            <option value="0">暂无试卷，请先组卷</option>
                            @else
                            @foreach ($examinations as $exams)
                            <option value="{{ $exams->id }}" @if(!empty($job)) @if($exams->id == $job->exam_id) selected @endif @endif >{{ $exams->name }}</option>
                            @endforeach
                            @endif
                        </select>
                    </div>
                    <div class="clear"></div>
              </div>
              <div id="jobs-hots-more" class="padd-t-30 ">
                  <button type="submit" id="getMoreJobs" class="btn-ok">发布</button>
                  <button type="button" id="" class="btn-cance">取消</button>
                  {!! csrf_field() !!}
                  <input type="hidden" name="blademode" value="{{ $blademode }}">
                  <input type="hidden" name="job_id" value="{{ !empty($job)?$job->jobs_id:0 }}">
                  <input type="hidden" name="gzxz" value="{{ !empty($job)?$job->gzxz:0 }}">
              </div>
            </form>
        </div>
         @else
          <div class="no-company-show">
                请先完善企业基本信息，谢谢！
          </div>
          @endif
    </div>
</div>
<script type="text/javascript">
    // 头部菜单导航样式
$(function() {
      $('#job_nature li').each(function(i,e){
                $(e).click(function(){
                  $('input[name=gzxz]').attr('value', i);
                    $('#job_nature').find('.color-white').attr('class', 'backgr-color-main margin-r-15');
                    $(this).attr('class', 'color-white backgr-color-4 margin-r-15');
                });
      });
    examinations();
});
function examinations()
{
        if($('input[name=test]:checked').val() == 1)
        {
            $("#examination").show();
        }
        else
        {
            $("#examination").hide();
        }
}

/**
 * 职位地区，根据父分类获取子分类
 */
function childAreas(pid,uri,id){
  $.ajax({
    'url':'/'+uri,
    'type':'GET',
    'data':'pid='+pid,
    error: function(request) {
      $('#'+id).html('<option value="0">没有更多分类</option>');
        },
    success: function(data){
      if(data.status == 'success'){
        var result = data.data;
        var options ="";
        var firstid;
                if(result.length > 0){
                    $.each(result,function(k,e){
                      if(k==0) firstid=e.area_id;
                        options +='<option value="'+e.area_id+'">'+e.title+'</option>';
                    });
                    if(id == 'city'){
                      childAreas(firstid,uri,'area');
                    }
                    $('#'+id).html(options);
                }else{
            $('#'+id).html('<option value="0">没有更多分类</option>');
          }
      }else{
        $('#'+id).html('<option value="0">没有更多分类</option>');
      }
    },
  });
}
var editor;
KindEditor.ready(function(K) {
	editor = K.create('.content', {	
    	resizeType : 1,
    	//allowPreviewEmoticons : false,
    	afterBlur: function () { this.sync(); },
    	allowImageUpload : true,
    	width : "100%", 
    	allowUpload : true,
    	//postParams:123,
    	//uploadJson : '/index.php?g=User&m=Upyun&a=kindedtiropic',
    	items : ["justifyleft", "justifycenter", "justifyright", ]
	});

});
</script>

@stop

<!--底部导航-->
@section('footer')
@parent
@stop

